package dao

import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	"time"
)

var db *sql.DB
func init()  {
	dsn:= "root:@tcp(127.0.0.1:3306)/week2?charset=utf8mb4&parseTime=True&loc=Local"
	_db, err := sql.Open("mysql", dsn)
	if err != nil {
		panic(err)
	}
	_db.SetMaxOpenConns(10)
	_db.SetConnMaxLifetime(time.Minute * 5)
	_db.SetMaxIdleConns(10)
	db = _db
}